package com.miniserver.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

/**
 * 处理请求的编码，设置输出的编码
 * 
 * @author keith
 * 
 */
@WebFilter(filterName = "a2encodingFilter", urlPatterns = "/*")
public class EncodingFilter implements Filter {
/**
 * 初始化
 */
	@Override
	public void init(FilterConfig arg0) throws ServletException {
	}
/**
 * 设置编码
 */
	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		filterChain.doFilter(request, response);
	}
/**
 * 销毁
 */
	@Override
	public void destroy() {
	}
}